<?php 
class Cmusic extends My_playelem {
	public function __construct() {
			# code...
		parent::__construct();
		$this->load->helper("url");			
	}
	
	public function index() {

		
	}

	public function playMusic($filename,$id) {
		$id=$this->decode_id($id);
		$data=$this->loadData();
		$data['list_song']=$this->Mmusic->getMusic($id);
		$data['info_elem']=$this->Mmusic->getSongInfo($id);
		$value=$data['info_elem'][0]['rating']+1;
		$this->Mmusic->updateRating($id,$value);
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idArtist');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idTheme');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idGenre');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idAlbum');

		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strNameAlbum','titleAlbum');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strArtist','titleArtist');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strGenre','titleGenre');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strTheme','titleTheme');
		$data['type_elem']='song';

		$this->template->add_title("{$data['list_song'][0]['strFileName']} - {$data['info_elem'][0]['strArtist']}");
		$this->template->add_js('views/user/public/js/jquery.min.js');
		$this->template->add_js('views/user/public/js/jquery-ui.js');
		$this->template->add_js('views/user/public/js/slimScroll.min.js');
		$this->template->add_js('views/user/public/js/mediaelement-and-player.min.js');


		$this->template->add_css('views/user/public/css/mediaelementplayer.min.css');
	

		$this->template->parse_view('content_center','user/module/content-playelem',$data);
		//$this->template->add_js('views/user/public/js/playelem.js');
		$this->template->render();
		
	
	}
	public function playAlbum($filename,$id) {
		$id=$this->decode_id($id);
		$data=$this->loadData();

	
		$data['info_elem']=$this->Malbum->getAlbumInfo($id);
		$data['list_song']=$this->Malbum->getSongAlbum($id);
		$data['type_elem']='album';
		$value=$data['info_elem'][0]['iRating']+1;
		$this->Malbum->updateRating($id,$value);
		$this->template->add_title("{$data['info_elem'][0]['strNameAlbum']} - {$data['list_song'][0]['strArtist']}");
		$this->template->add_js('views/user/public/js/jquery.min.js');
		$this->template->add_js('views/user/public/js/jquery-ui.js');
		$this->template->add_js('views/user/public/js/slimScroll.min.js');
		$this->template->add_js('views/user/public/js/mediaelement-and-player.min.js');


		$this->template->add_css('views/user/public/johnyer/mediaelementplayer.min.css');
		$this->template->add_css('views/user/public/css/content-center-play.css');
	

		$this->template->parse_view('content_center','user/module/content-playelem',$data);
		$this->template->render();

	}

	public function playVideo($filename,$id) {
		$id=$this->decode_id($id);
		$data=$this->loadData();

		$data['info_elem']=$this->Mvideo->getVideo($id);
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idArtist');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idTheme');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idGenre');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idAlbum');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strNameAlbum','titleAlbum');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strArtist','titleArtist');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strGenre','titleGenre');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strTheme','titleTheme');
		$data['type_elem']='video';

		$this->template->add_title("{$data['info_elem'][0]['strFileName']} - {$data['info_elem'][0]['strArtist']}");
		$this->template->add_js('views/user/public/js/jquery.min.js');
		$this->template->add_js('views/user/public/js/jquery-ui.js');
		$this->template->add_js('views/user/public/js/slimScroll.min.js');
		$this->template->add_js('views/user/public/johnyer/mediaelement-and-player.min.js');


		$this->template->add_css('views/user/public/johnyer/mediaelementplayer.min.css');
	

		$this->template->parse_view('content_center','user/module/content-playelem',$data);
		$this->template->render();


	}
	public function playPlaylist($filename,$id) {
		$id=$this->decode_id($id);
		$data=$this->loadData();
		$this->load->Model('Mplaylist');
		$data['info_elem']=$this->Mplaylist->getPlaylist($id);
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idPlaylist');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idTheme');
		$data['info_elem']=parent::getBase64Code($data['info_elem'],'idGenre');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strNamePList','titlePlist');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strGenre','titleGenre');
		$data['info_elem']=parent::convertStringUrl($data['info_elem'],'strTheme','titleTheme');
		$data['type_elem']='playlist';
		$data['list_song']=$this->Mplaylist->getSongPlaylist($id);
		$value=$data['info_elem'][0]['rating']+1;
		$this->Mplaylist->updateRating($id,$value);
		$this->template->add_title("{$data['info_elem'][0]['strNamePList']}-playlist-nghenhac.vn");
		$this->template->add_js('views/user/public/js/jquery.min.js');
		$this->template->add_js('views/user/public/js/jquery-ui.js');
		$this->template->add_js('views/user/public/js/slimScroll.min.js');
		$this->template->add_js('views/user/public/johnyer/mediaelement-and-player.min.js');


		$this->template->add_css('views/user/public/johnyer/mediaelementplayer.min.css');
	

		$this->template->parse_view('content_center','user/module/content-playelem',$data);
		$this->template->render();


	}

	public function loadData() {
		$this->load->Model('Mmusic');
		$this->load->Model('Mgenre');
		$data['data_listSong_hot']=$this->Mmusic->getTopSong(10);
		$data['data_listGenre']=$this->Mgenre->getAllGenre();
		$data['data_bxh_video']=$this->Mvideo->getTopVideo(10);
		$data['data_listSong_hot']=parent::getBase64Code($data['data_listSong_hot'],'idSong');
		$data['data_listSong_hot']=parent::getBase64Code($data['data_listSong_hot'],'idArtist');
		$data['data_listSong_hot']=parent::convertStringUrl($data['data_listSong_hot'],'strFileName','title');
		$data['data_listSong_hot']=parent::convertStringUrl($data['data_listSong_hot'],'strArtist','titleArtist');
		$data['data_bxh_video']=parent::getBase64Code($data['data_bxh_video'],'idVideo');
		$data['data_bxh_video']=parent::getBase64Code($data['data_bxh_video'],'idArtist');
		$data['data_bxh_video']=parent::convertStringUrl($data['data_bxh_video'],'strFileName','titleVideo');
		$data['data_bxh_video']=parent::convertStringUrl($data['data_bxh_video'],'strArtist','titleArtist');
		$data['data_bxh_video']=parent::convertStringUrl($data['data_bxh_video'],'strExtraArtist','titleExtraArtist');
		$data['data_listGenre']=parent::getBase64Code($data['data_listGenre'],'idGenre');
		return $data;
	}

}

 ?>